﻿<%@ Page Title="" Language="C#" MasterPageFile="~/BackEnd/BackEndMasterPage.Master" AutoEventWireup="true"
    EnableEventValidation="false" CodeBehind="InsertFaculty.aspx.cs" Inherits="AteneoLibri.BackEnd.InsertFaculty" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <h2>
        Inserisci facoltà
    </h2>
    <asp:Panel ID="pnlSelectUniversity" runat="server">
        <h3>
            Seleziona l'università di appertenenza</h3>
        <asp:DropDownList ID="ddlUniversities" runat="server" CssClass="StandardTextBox"
            DataTextField="Name" DataValueField="IdUniversity" ValidationGroup="vgInsertFaculty"
            AutoPostBack="true" AppendDataBoundItems="true">
            <asp:ListItem Selected="True" Enabled="true" Value="0">-- Seleziona --</asp:ListItem>
        </asp:DropDownList>
        <asp:HiddenField ID="hfUniversityId" runat="server" />
    </asp:Panel>
    <asp:Panel ID="pnlInsertFaculty" runat="server" DefaultButton="btnInsertFaculty"
        Visible="false">
        <h3>
            Inserisci la nuova facoltà per:
            <asp:Label ID="uniName" runat="server"></asp:Label></h3>
        <div>
            <asp:TextBox ID="txtFaculty" runat="server" CssClass="StandardTextBox" Height="20px"
                ValidationGroup="vgInsertFaculty"></asp:TextBox>
            <asp:Button ID="btnInsertFaculty" runat="server" CssClass="StandardButton" Text="Inserisci"
                ValidationGroup="vgInsertFaculty" OnClick="btnInsertFaculty_Click" />
        </div>
        <div>
            <asp:RequiredFieldValidator ID="rfvUni" runat="server" ErrorMessage="* Campo obbligatorio"
                ValidationGroup="vgInsertFaculty" ControlToValidate="txtFaculty" Display="Dynamic"
                CssClass="failureNotification"></asp:RequiredFieldValidator>
        </div>
    </asp:Panel>
    <div style="margin-top: 20px;">
        <asp:Panel ID="pnlFaculties" runat="server" Visible="false">
            <h3>
                Elenco delle facoltà inserite</h3>
            <asp:GridView ID="gvFaculties" runat="server" EmptyDataText="Non ci sono facoltà presenti nel database"
                AlternatingRowStyle-BackColor="#cccccc" BackColor="#ffffff" CellPadding="2" AutoGenerateColumns="false"
                ShowFooter="true" DataKeyNames="IdFaculty" PageSize="15" EmptyDataRowStyle-ForeColor="Red">
                <Columns>
                    <asp:BoundField HeaderText="Nome facoltà" ReadOnly="true" DataField="Name" ItemStyle-Width="200px" />
                    <asp:TemplateField>
                        <ItemTemplate>
                            <asp:ImageButton ID="btnDeleteNation" runat="server" CssClass="metroButton" AlternateText="Cancella la facoltà"
                                ImageUrl="~/Images/deleteIcon.png" OnClick="btnDeleteFaculty_Click" CommandArgument='<%# Eval("IdFaculty") %>' />
                        </ItemTemplate>
                    </asp:TemplateField>
                    <%--<asp:TemplateField>
                    <HeaderTemplate>
                        <asp:Label ID="Label1" runat="server" Text="Università"></asp:Label>
                    </HeaderTemplate>
                    <ItemTemplate>
                        <asp:Label ID="lblUniversity" runat="server" Text='<%# Bind("University") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>--%>
                </Columns>
            </asp:GridView>
        </asp:Panel>
    </div>
</asp:Content>
